package com.test.redis.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @program: spring-cloud-demo
 * @description: redis测试类
 * @author: lyr
 * @create: 2018-06-04 11:00
 **/
@Component
@Slf4j
public class RedisTestService implements CommandLineRunner {

    @Autowired
    private RedisService redisService;

    @Override
    public void run(String... args) throws Exception {
        for (int i = 0; i < 10; i++) {
            String key = "hello" + i;
            String value = "this is a test value " + i;
            log.debug("测试redis写入数据，key：" + key + "；value：" + value);
            redisService.set("hello1", value);
            Object result = redisService.get("hello1");
            log.debug("测试redis读取数据，key：" + key + "；value：" + result);
        }
    }
}
